import { createBrowserRouter, Navigate } from "react-router-dom";
import Login from "../pages/login";
import Home from "../pages/home";
import HomeIndex from "../pages/home/homeIndex";
import { lazy, Suspense } from "react";
import Loading from "../components/loading";

// 收货管理
const ASN = lazy(() => import("../pages/home/receiving/ASN"));
const ASNDetail = lazy(() => import("../pages/home/receiving/ASN/detail"));
const ReceiptGoods = lazy(
  () => import("../pages/home/receiving/ASN/receiptGoods")
);

// 库存管理
const InventoryQuery = lazy(
  () => import("../pages/home/inventory/inventoryQuery")
);
const InventoryRecord = lazy(
  () => import("../pages/home/inventory/inventoryRecord")
);

// 出库管理
const LoadDispatch = lazy(() => import("../pages/home/outbound/loadDispatch"));
const OutboundBoxQuery = lazy(
  () => import("../pages/home/outbound/outboundBoxQuery")
);
const OutboundOrderQuery = lazy(
  () => import("../pages/home/outbound/outboundOrderQuery")
);
const PackingReview = lazy(
  () => import("../pages/home/outbound/packingReview")
);
const TaskManagement = lazy(
  () => import("../pages/home/outbound/taskManagement")
);
const WaveTimeQuery = lazy(
  () => import("../pages/home/outbound/waveTimeQuery")
);
// 报表管理
const ReportCenter = lazy(() => import("../pages/home/report/reportCenter"));

// 基础资料
const CarrierManagement = lazy(
  () => import("../pages/home/data/carrierManagement")
);
const WarehouseMasterDocument = lazy(
  () => import("../pages/home/data/warehouseMasterDocument")
);

const router = createBrowserRouter([
  {
    path: "/",
    element: <Navigate to="/login" />,
  },
  {
    path: "/login",
    element: <Login />,
  },
  {
    path: "/home",
    element: <Home />,
    children: [
      {
        path: "",
        element: <Navigate to="/home/homeindex" />,
      },
      //首页
      {
        path: "homeindex",
        element: <HomeIndex />,
      },
      // 收货管理
      {
        path: "ASN",
        element: (
          <Suspense fallback={<Loading />}>
            <ASN />
          </Suspense>
        ),
      },
      {
        path: "ASNDetail",
        element: (
          <Suspense fallback={<Loading />}>
            <ASNDetail />
          </Suspense>
        ),
      },
      {
        path: "ReceiptGoods",
        element: (
          <Suspense fallback={<Loading />}>
            <ReceiptGoods />
          </Suspense>
        ),
      },
      // 库存管理
      {
        path: "inventoryQuery",
        element: (
          <Suspense fallback={<Loading />}>
            <InventoryQuery />
          </Suspense>
        ),
      },
      {
        path: "inventoryRecord",
        element: (
          <Suspense fallback={<Loading />}>
            <InventoryRecord />
          </Suspense>
        ),
      },
      // 出库管理
      {
        path: "outboundBoxQuery",
        element: (
          <Suspense fallback={<Loading />}>
            <OutboundBoxQuery />
          </Suspense>
        ),
      },
      {
        path: "loadDispatch",
        element: (
          <Suspense fallback={<Loading />}>
            <LoadDispatch />
          </Suspense>
        ),
      },
      {
        path: "outboundOrderQuery",
        element: (
          <Suspense fallback={<Loading />}>
            <OutboundOrderQuery />
          </Suspense>
        ),
      },
      {
        path: "taskManagement",
        element: (
          <Suspense fallback={<Loading />}>
            <TaskManagement />
          </Suspense>
        ),
      },
      {
        path: "waveTimeQuery",
        element: (
          <Suspense fallback={<Loading />}>
            <WaveTimeQuery />
          </Suspense>
        ),
      },
      {
        path: "packingReview",
        element: (
          <Suspense fallback={<Loading />}>
            <PackingReview />
          </Suspense>
        ),
      },
      // 报表管理
      {
        path: "reportCenter",
        element: (
          <Suspense fallback={<Loading />}>
            <ReportCenter />
          </Suspense>
        ),
      },
      // 基础资料
      {
        path: "warehouseMasterDocument",
        element: (
          <Suspense fallback={<Loading />}>
            <WarehouseMasterDocument />
          </Suspense>
        ),
      },
      {
        path: "carrierManagement",
        element: (
          <Suspense fallback={<Loading />}>
            <CarrierManagement />
          </Suspense>
        ),
      },
    ],
  },
  {
    path: "*",
    element: <div>404错误</div>,
  },
]);
export default router;
